import { numberFormat } from "@/util/util.js";
export const tableOptionOffineTicket = {
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  menu: false,
  header: false,
  column: [
    {
      type: "input",
      label: "唯一标识",
      prop: "id",
      hide: true
    },
    {
      type: "input",
      label: "主表关联ID",
      prop: "relationId",
      hide: true
    },
    {
      type: "input",
      label: "车票类型",
      prop: "ticketType",
      hide: true
    },
    {
      type: "select",
      label: "车票名称",
      prop: "ticketName",
      width: 150,
      dicUrl: "/support/swpmticketcardtypeparam/dict/YXCP",
      cell: true,
      props: {
        label: "subName",
        value: "subEnName"
      },
      component: "ticket-select",
      params: {
        valueKey: "ticketPrice",
        unitKey: "ticketUnit"
      }
    },
    {
      type: "number",
      label: "票价",
      prop: "ticketPrice",
      precision: "2",
      //cell: true,
      formatter: (row, value, label, column) => {
        // return numberFormat(value, column.precision)
        return `${row.ticketPrice == null ? 0 : row.ticketPrice}`;
      }
    },
    {
      type: "input",
      label: "售卖张数",
      prop: "ticketNum",
      cell: true
    },
    {
      type: "number",
      label: "售卖金额",
      prop: "sellAmount",
      precision: 2,
      formatter: (row, value, label, column) => {
        const ticketPrice = row.ticketPrice;
        const ticketNum = row.ticketNum;
        let money = 0;
        if (ticketPrice && ticketNum) {
          money = ticketPrice * ticketNum;
        }
        row.sellAmount = money;
        return numberFormat(money, column.precision);
      }
    },
    {
      type: "select",
      label: "取票方式",
      prop: "takeTicketWay",
      cell: true,
      dicUrl: "/admin/dict/type/take_ticket_type"
    },
    {
      type: "input",
      label: "回执单号",
      prop: "ticketWayNum",
	  hide:true,
      cell: true
    },
    {
      type: "date",
      label: "日期",
      prop: "takeTicketTime",
      width: 150,
      cell: true,
      format: "yyyy-MM-dd",
      valueFormat: "yyyy-MM-dd"
    },
    {
      dataType: "string",
      type: "upload",
      label: "回执单附件",
      prop: "receiptFilePath",
      cell: true,
      component: "zd-upload",
      limit: 1
    },
    {
      type: "input",
      label: "创建时间",
      prop: "createTime",
      hide: true
    },
    {
      type: "input",
      label: "数据更新时间",
      prop: "updateTime",
      hide: true
    },
    {
      type: "input",
      label: "删除标志 1：删除 0：未删",
      prop: "delFlag",
      hide: true
    }
  ]
};

export const tableOptionOffineTicketView = {
  border: true,
  index: true,
  indexLabel: "序号",
  stripe: true,
  menuAlign: "center",
  align: "center",
  detail: true,
  menu: false,
  header: false,
  column: [
    {
      type: "input",
      label: "唯一标识",
      prop: "id",
      hide: true
    },
    {
      type: "input",
      label: "主表关联ID",
      prop: "relationId",
      hide: true
    },
    {
      type: "input",
      label: "车票类型",
      prop: "ticketType",
      hide: true
    },
    {
      type: "select",
      label: "车票名称",
      prop: "ticketName",
      width: 150,
      dicUrl: "/support/swpmticketcardtypeparam/dictAll/YXCP",
      cell: true,
      props: {
        label: "subName",
        value: "subEnName"
      },
      component: "ticket-name-select",
      params: {
        valueKey: "ticketPrice",
        unitKey: "ticketUnit"
      }
    },
    {
      type: "number",
      label: "票价",
      prop: "ticketPrice",
      precision: "2",
      //cell: true,
      formatter: (row, value, label, column) => {
        // return numberFormat(value, column.precision)
        return `${row.ticketPrice == null ? "" : row.ticketPrice}`;
      }
    },
    {
      type: "input",
      label: "售卖张数",
      prop: "ticketNum",
      cell: true
    },
    {
      type: "number",
      label: "售卖金额",
      prop: "sellAmount",
      precision: 2,
      cell: true,
      formatter: (row, value, label, column) => {
        return numberFormat(value, column.precision);
      }
    },
    {
      type: "select",
      label: "取票方式",
      prop: "takeTicketWay",
      cell: true,
      dicUrl: "/admin/dict/type/take_ticket_type"
    },
    {
      type: "input",
      label: "回执单号",
      prop: "ticketWayNum",
	  hide:true,
      cell: true
    },
    {
      type: "date",
      label: "日期",
      prop: "takeTicketTime",
      width: 150,
      cell: true,
      format: "yyyy-MM-dd",
      valueFormat: "yyyy-MM-dd"
    },
    {
      type: "upload",
      label: "回执单附件路径",
      prop: "receiptFilePath",
      slot: true
    },
    {
      type: "input",
      label: "创建时间",
      prop: "createTime",
      hide: true
    },
    {
      type: "input",
      label: "数据更新时间",
      prop: "updateTime",
      hide: true
    },
    {
      type: "input",
      label: "删除标志 1：删除 0：未删",
      prop: "delFlag",
      hide: true
    }
  ]
};
